package com.itheima.case2.controller;

import com.itheima.case2.exception.BusinessException;
import com.itheima.case2.pojo.vo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException businessException){

        String message = businessException.getMessage();
        return new Result(false,message);
    }

    @ExceptionHandler(Exception.class)
    public Result doException(Exception e){
        e.printStackTrace();
        return new Result(false,"服务器繁忙，请稍后重试");

    }
}
